package com.my.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 地址统一识别代码表-接口调用
 * </p>
 *
 * @author generator
 * @since 2024-07-22
 */
@Data
@Builder
@Accessors(chain = true)
@TableName("app_ys_tysbdm")
@Schema(name = "TysbdmDO", description = "地址统一识别代码表-接口调用")
public class TysbdmDO extends Model<TysbdmDO> {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @Schema(description = "行政区划编码")
    @TableField("region_code")
    private String regionCode;

    @Schema(description = "分类编目码")
    @TableField("type_code")
    private String typeCode;

    @Schema(description = "行业代码")
    @TableField("entity_id")
    private String entityId;

    @Schema(description = "业务系统的名称")
    @TableField("entity_name")
    private String entityName;

    @Schema(description = "经度北斗码")
    @TableField("lon")
    private String lon;

    @Schema(description = "纬度北斗码")
    @TableField("lat")
    private String lat;

    @Schema(description = "北斗网格位置码2d（接口返回）")
    @TableField("beidou_2d")
    private String beidou2d;

    @Schema(description = "北斗网格位置码3d（接口返回）")
    @TableField("beidou_3d")
    private String beidou3d;

    @Schema(description = "统一识别代码（接口返回）")
    @TableField("code")
    private String code;

    @Schema(description = "处理状态(0 待处理 1 处理成功 2 处理失败)")
    @TableField("status")
    private Integer status;

    @Schema(description = "最后一次发起时间")
    @TableField("request_time")
    private LocalDateTime requestTime;

    @Schema(description = "异常消息")
    @TableField("message")
    private String message;

    @Override
    public Serializable pkVal() {
        return this.id;
    }


    public MultiValueMap<String, String> buildParams() {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("region_code", regionCode);
        params.add("type_code", typeCode);
        params.add("entity_id", entityId);
        params.add("entity_name", entityName);
        params.add("lon", lon);
        params.add("lat", lat);
        return params;
    }
}
